
using Mistral;
using Mistral.SectFile;

namespace Conditions.Section
{
	public class Condition_Section_KeyEquals : ICondition<ISection>
	{
		string m_keyName;
		string m_keyValue;
		bool m_bIgnoreCase;

		public Condition_Section_KeyEquals( string keyName, string keyValue ):
			this( keyName, keyValue, true )
		{
		}

		public Condition_Section_KeyEquals( string keyName, string keyValue, bool bIgnoreCase )
		{
			m_keyName = keyName;
			m_keyValue = keyValue;
			m_bIgnoreCase = bIgnoreCase;
		}

		#region ICondition<ISection> Members

		public bool Matches( ISection value )
		{
			string keyValue = value.GetValue( m_keyName, string.Empty );
			return ( string.Compare( m_keyValue, keyValue, m_bIgnoreCase ) == 0 );
		}

		#endregion
	}
}